if size(lena512,3)>1
img0 = rgb2gray(uint8(lena512));
else
    img0 = uint8(lena512);
end
if size(lena_dark, 3)>1
img1 = rgb2gray(uint8(lena_dark));
else
    img1 = uint8(lena_dark);
end
figure;
subplot(2,1,1)
imshow(img0);
subplot(2,1,2)
imshow(img1);
for idx=1:100
    [img1, img0] = histogram_match(img0, img1);
end
figure;
subplot(2,1,1)
imshow(img0);
subplot(2,1,2)
imshow(img1);
